x86/svm: VMEntry/Exit logic for MSR_SPEC_CTRL
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 21 Jan 2022 15:59:03 +0000 (15:59 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 4 Feb 2022 15:45:25 +0000 (15:45 +0000)
commit142c6bd63468b147299f1393e8347d76fe6c3270
tree76cfdd04149369ed160c76409dbbffe16e44a5d7
parente7ccc7a8ab92502a12dc31f652b0ca3b1be04b7e
x86/svm: VMEntry/Exit logic for MSR_SPEC_CTRL

Hardware maintains both host and guest versions of MSR_SPEC_CTRL, but guests
run with the logical OR of both values.  Therefore, in principle we want to
clear Xen's value before entering the guest.  However, for migration
compatibility (future work), and for performance reasons with SEV-SNP guests,
we want the ability to use a nonzero value behind the guest's back.  Use
vcpu_msrs to hold this value, with the guest value in the VMCB.

On the VMEntry path, adjusting MSR_SPEC_CTRL must be done after CLGI so as to
be atomic with respect to NMIs/etc.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit 614cec7d79d76786f5638a6e4da0576b57732ca1)
xen/arch/x86/hvm/svm/entry.S
xen/arch/x86/x86_64/asm-offsets.c
xen/include/asm-x86/msr.h
xen/include/asm-x86/spec_ctrl_asm.h